<html>
<head>
<title>国际足球球队信息数据采集</title>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body{}
td{}
</style>
</head>
<form action="#">
	<input type="text" name="url" value="">
	<input type="submit" value="查询">
</form>
<?php
/**
 * 数据采集
 */
header('Content-type: text/html; charset=utf-8');

$url = @$_GET["url"];
if ($url == "") {
	return;
}

//连接数据库
$config = require 'conf/config.ini.php';      //加载公用config.ini.php
$conn = mysql_connect($config["DB_HOST"], $config["DB_USER"], $config["DB_PWD"]);
mysql_select_db($config["DB_NAME"], $conn);
mysql_query("SET NAMES utf8");

$teamList = file_get_contents($url);
$teamList = json_decode($teamList);

foreach ($teamList as $team) {
	$sql = "delete from live_team_f where id = '" . $team->teamOfficialId . "';";
	mysql_query($sql, $conn);
	$sql = "INSERT INTO live_team_f (id, name, name_en, name_tw, nation, competition, site, `join`, pic, website, season) VALUES";
	$sql .= "(". $team->teamOfficialId .",'". $team->team ."','". $team->teameName ."','". $team->cantonName ."','". $team->nation ."','". $team->competitionName ."','". $team->venue ."','". substr($team->foundDt,0,4) ."','http://img1.cache.netease.com/sports/2009/goal/logo/team/70/t". $team->teamOfficialId .".gif','". $team->website ."','". $team->seasonId ."')";
	mysql_query($sql, $conn);
}

?>